﻿using Huirui.Cavan.Domain.Seedwork;
using System;
using System.Collections;
using System.Collections.Generic;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    #region UserAccount

    /// <summary>
    /// UserAccount object for NHibernate mapped table 'UserAccount'.
    /// </summary>
    [Serializable]
    public class UserAccount : Persistent
    {
        #region Member Variables

        protected string _name;
        protected string _password;
        protected string _email;
        protected decimal _creditLimit;
        protected DateTime _lastActiveTime;
        protected bool _isLocked;
        protected Role _role;
        protected Employee _employee;
        protected UserAccountProperty _userAccountProperty;

        #endregion

        #region Constructors

        public UserAccount() { }

        public UserAccount(string name, string password, string email, decimal creditLimit, DateTime lastActiveTime, bool isLocked, bool isDeleted, DateTime createDate, DateTime modifyDate, int editUser, Employee employee)
        {
            this._name = name;
            this._password = password;
            this._email = email;
            this._creditLimit = creditLimit;
            this._lastActiveTime = lastActiveTime;
            this._isLocked = isLocked;
            this._isDeleted = isDeleted;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._employee = employee;
        }

        #endregion

        #region Public Properties


        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 50)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual string Password
        {
            get { return _password; }
            set
            {
                if (value != null && value.Length > 50)
                    throw new ArgumentOutOfRangeException("Invalid value for Password", value, value.ToString());
                _password = value;
            }
        }

        public virtual string Email
        {
            get { return _email; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Email", value, value.ToString());
                _email = value;
            }
        }

        public virtual decimal CreditLimit
        {
            get { return _creditLimit; }
            set { _creditLimit = value; }
        }

        public virtual DateTime LastActiveTime
        {
            get { return _lastActiveTime; }
            set { _lastActiveTime = value; }
        }

        public virtual bool IsLocked
        {
            get { return _isLocked; }
            set { _isLocked = value; }
        }

        public virtual Employee Employee
        {
            get { return _employee; }
            set { _employee = value; }
        }

        public virtual Role Role
        {
            get
            {
                if (_role == null)
                {
                    _role = new Role();
                }
                return _role;
            }
            set
            {
                _role = value;
            }
        }

        public virtual UserAccountProperty UserAccountProperty
        {
            get
            {
                if (_userAccountProperty == null)
                {
                    _userAccountProperty = new UserAccountProperty();
                }
                return _userAccountProperty;
            }
            set
            {
                _userAccountProperty = value;
            }
        }
        #endregion
    }
    #endregion
}